package k1_exercise;

import java.util.Arrays;

public class Array_twoArrayHeadTailSwap {

    /**
     * 两个数组首尾交换 {1,2,3,4},{5,6,7,8}  ->  {8,7,6,5},{4,3,2,1}
     */
    public static void main(String[] args) {
        //初始化两个数组
        int[] nums_a = {1,2,3,4};
        int[] nums_b = {5,6,7,8};

        int tmp = 0;

        for (int i = 0; i < nums_a.length; i++) {
            tmp = nums_a[i];
            nums_a[i] = nums_b[nums_a.length-1-i];
            nums_b[nums_a.length-1-i] = tmp;
        }

        System.out.println(Arrays.toString(nums_a));
        System.out.println(Arrays.toString(nums_b));

    }

}
